﻿using Autofac;
using Autofac.Extensions.DependencyInjection;

namespace Project.Yan.Net.Autofac
{
    public static class AutofacConfig
    {
        public static void ConfigureContainer(WebApplicationBuilder builder)
        {
            // 第一步：先替换服务工厂
            builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());

            // 第二步：配置Autofac容器（由工厂自动调用）
            builder.Host.ConfigureContainer<ContainerBuilder>(autofacBuilder =>
            {
                autofacBuilder.RegisterModule<DALModule>();
                autofacBuilder.RegisterModule<BLLModule>();
            });
        }
    }

}
